<%@ page contentType="text/html;charset=utf-8" 
	import="org.springframework.web.context.*,org.springframework.web.context.support.*,java.util.*,com.zh.UserBean,com.zh.Util"
%>
<html>
  <head>
    <title>添加业主信息</title>
     <script language="javascript">
	String.prototype.trim = function(){
      return this.replace(/(^\s*)|(\s*$)/g, "");
    }
    function check(){
      var username=document.all.username.value;
      var houseaddress=document.all.houseaddress.value;
      var usersex=document.all.usersex.value;
      var userprofession=document.all.userprofession.value;
      var telp=document.all.telp.value;
      var livet=document.all.livet.value;
      var livecont=document.all.livecont.value;
      if(username.trim()==""){
       alert("姓名不能为空");
		    return;
      }
      if(houseaddress.trim()==""){
       alert("地址不能为空");
		    return;
      }
      if(usersex.trim()==""){
       alert("性别不能为空");
		    return;
      }
      if(userprofession.trim()==""){
       alert("职业不能为空");
		    return;
      }
      if(telp.trim()==""){
       alert("电话不能为空");
		    return;
      }
      if(livet.trim()==""){
       alert("入住时间不能为空");
		    return;
      }
      if(livecont.trim()==""){
       alert("入住人数不能为空");
		    return;
      }
      document.all.ss.submit();
    }
	</script>
	 <style>
	       table{
	         border-collapse:collapse;
	       }
	       table,tr,td {
	       
	       border:1px solid black;
	       }
	       .mima {
	       width:100%;
	       height:40px;
	       background-color:#ADD8E6;
	       }
	       .zi {
	       font-size:20px;
	       position:relative;
	       left:45%;
	       margin-left:-30px;
	       line-height:40px;
	       }
	</style>
  </head>
  <body>
 	<jsp:useBean id="userBean" class="com.zh.UserBean" scope="session"/>
	<div class="mima"><font class="zi">添加业户信息</font></div>
	<form action="SuperServlet" method="post" id="ss">
	<table  width="80%" border="1" cellspacing="0" style="margin-left:150px;margin-top:15px">	
	  <tr >
	    <td align="right" height="30px" width="40%">业主姓名:</td>
	    <td><input type="text" id="username" name="username"/></td>
	  </tr>
	  <tr >
	  	<td align="right" height="30px">居住地址:</td>
	  	<td>
      	  <select name="houseaddress">
      	  <% 
			//获取WebApplicationContext
			WebApplicationContext w=
			   WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
			Util util = (Util)w.getBean("Util");
			List<String> li= util.getHouseAddress();
		
			for(String username:li){
  	   			
      	    %>
      	    	<option value="<%= username %>" ><%= username %></option>
      	    <% 
      	    	}
      	     %>
      	  </select>
	  	</td>
	  </tr>
	  <tr >
	  	<td align="right" height="30px">业主性别:</td>
	  	<td><input type="text" id="usersex" name="usersex"/></td>
	  </tr>
	  <tr >
	  	<td align="right" height="30px"> 业主职业:</td>
	  	<td><input type="text" id="userprofession" name="userprofession"/></td>
	  </tr>
	  <tr >
	  	<td align="right" height="30px">业主电话:</td>
	  	<td><input type="text" id="telp" name="telp"/></td>
	  </tr>
	  <tr >
	  	<td align="right" height="30px">入住时间:</td>
	  	<td><input type="date" id="livet" name="livet"/></td>
	  </tr>	
	  <tr >
	  	<td align="right" height="30px">居住人数:</td>
	  	<td><input type="text" id="livecont" name="livecont"/></td>
	  </tr>
	  
	   <tr height="30px" >
		   <td  colspan="2">
		   <div  style="position:relative;left:40%;">
		   <input type="button" value="提交" id="xg" onclick="JavaScript:check()" style="cursor:hand"/>
		   <input type="button" value="重置" id="cz" onclick="JavaScript:document.all.ss.reset()"  style="cursor:hand">
		   </div>
		   </td>
		 </tr>
	</table>
	
	<input type="hidden" name="action" value="addu"/>
	
	
	</form>
  </body>
</html>